package com.yaozheng.vocationaltraining.fragment;

import android.support.v4.widget.SwipeRefreshLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.adapter.MyExperienceTitleAdapter;
import com.yaozheng.vocationaltraining.manage.ListViewLoadMoreManage;
import com.yaozheng.vocationaltraining.utils.JsonUtils;

import net.sf.json.JSONArray;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

/**
 * 我的经验头衔
 */
@EFragment(R.layout.fragment_integral_details)
public class MyExperienceTitleFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
    @ViewById
    ListView listView;

    @ViewById
    TextView headTitleText;

    /**
     * 下拉刷新
     */
    @ViewById
    SwipeRefreshLayout swipeRefreshLayout;

    MyExperienceTitleAdapter myExperienceTitleAdapter;

    int experience;

    public void setExperience(int experience) {
        this.experience = experience;
    }

    @AfterViews
    public void initView() {
        headTitleText.setText("头衔");

//        swipeRefreshLayout.postDelayed(new Runnable() {

//            @Override
//            public void run() {
        swipeRefreshLayout.setRefreshing(true);
        swipeRefreshLayout.setOnRefreshListener(this);
//        listViewLoadMoreManage = new ListViewLoadMoreManage(this,
//                getBaseActivity(), listView);
//            }

        JSONArray dataList = JsonUtils.getJsonArray("[" +
                "{\"value\":\"新兵\",\"fraction\":\"0-50\"}," +
                "{\"value\":\"五等兵\",\"fraction\":\"51-200\"}," +
                "{\"value\":\"四等兵\",\"fraction\":\"201-500\"}," +
                "{\"value\":\"三等兵\",\"fraction\":\"501-1000\"}," +
                "{\"value\":\"二等兵\",\"fraction\":\"1001-1500\"}," +
                "{\"value\":\"一等兵\",\"fraction\":\"1501-2000\"}," +
                "{\"value\":\"二级下士\",\"fraction\":\"2001-3000\"}," +
                "{\"value\":\"一级下士\",\"fraction\":\"3001-4000\"}," +
                "{\"value\":\"中士\",\"fraction\":\"4001-5000\"}," +
                "{\"value\":\"上士\",\"fraction\":\"5001-7000\"}," +
                "{\"value\":\"三级军士长\",\"fraction\":\"7001-9000\"}," +
                "{\"value\":\"二级军士长\",\"fraction\":\"9001-10000\"}," +
                "{\"value\":\"一级军士长\",\"fraction\":\"10001-12000\"}," +
                "{\"value\":\"少尉\",\"fraction\":\"12001-14000\"}," +
                "{\"value\":\"中尉\",\"fraction\":\"14001-16000\"}," +
                "{\"value\":\"上尉\",\"fraction\":\"16001-18000\"}," +
                "{\"value\":\"大尉\",\"fraction\":\"18001-20000\"}," +
                "{\"value\":\"少校\",\"fraction\":\"20001-23000\"}," +
                "{\"value\":\"中校\",\"fraction\":\"23001-26000\"}," +
                "{\"value\":\"上校\",\"fraction\":\"26001-29000\"}," +
                "{\"value\":\"准将\",\"fraction\":\"29001-33000\"}," +
                "{\"value\":\"少将\",\"fraction\":\"33001-37000\"}," +
                "{\"value\":\"中将\",\"fraction\":\"37001-41000\"}," +
                "{\"value\":\"上将\",\"fraction\":\"＞41000\"}," +
                "]");

        myExperienceTitleAdapter = new MyExperienceTitleAdapter(dataList, getBaseActivity());
        myExperienceTitleAdapter.setExperience(experience);
        listView.setAdapter(myExperienceTitleAdapter);
    }

    @Override
    public void onRefresh() {

    }
}
